package com.shrcl.engineerprocess.web.server.service.login.impl;

import com.shrct.businessprocess.organization.RCEmployeeUser;
import com.shrct.businessprocess.organization.RCSecurityService;
import edu.fudan.langlab.domain.security.AppFunction;
import edu.fudan.langlab.domain.security.User;
import edu.fudan.langlab.security.shared.FunctionIdentifier;
import edu.fudan.langlab.security.shared.IFunctionIdentifier;
import edu.fudan.langlab.uidl.domain.app.server.service.login.ISecurityService;
import edu.fudan.mylang.pf.BaseService;
import java.util.Collection;
import java.util.List;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Service;

@Service("com.shrcl.engineerprocess.web.server.service.login.RCUISecurityService")
public class RCUISecurityServiceImpl extends BaseService implements ISecurityService {
  @Autowired
  private RCSecurityService securityService;
  
  @Autowired
  private MailSender mailSender;
  
  @Autowired
  private SimpleMailMessage preConfiguredMessage;
  
  public User login(final String userid, final String passwd) {
    RCEmployeeUser _employeeUserLogin = this.securityService.employeeUserLogin(userid, passwd);
    return _employeeUserLogin;
  }
  
  public Collection<? extends IFunctionIdentifier> loadValidFunctions4User(final String userid) {
    Collection<AppFunction> _loadAllFunctions = this.securityService.loadAllFunctions(userid);
    final Function1<AppFunction,FunctionIdentifier> _function = new Function1<AppFunction,FunctionIdentifier>() {
        public FunctionIdentifier apply(final AppFunction it) {
          String _functionId = it.getFunctionId();
          FunctionIdentifier _functionIdentifier = new FunctionIdentifier(_functionId);
          return _functionIdentifier;
        }
      };
    Iterable<FunctionIdentifier> _map = IterableExtensions.<AppFunction, FunctionIdentifier>map(_loadAllFunctions, _function);
    List<FunctionIdentifier> _list = IterableExtensions.<FunctionIdentifier>toList(_map);
    return _list;
  }
}
